﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;

namespace VisualRibbonEditor
{
	/// <summary>
	/// Interaction logic for GroupSection.xaml
	/// </summary>
	public partial class GroupSection : UserControl
	{
		public GroupSection( XElement overflowSection )
		{
			InitializeComponent();

			if (overflowSection != null)
			{
				//read the templateAlias and displaymode from the overflowsection:
				//<OverflowSection Type="OneRow" TemplateAlias="o1" DisplayMode="Large" />
				string templateAlias = overflowSection.AttributeValue("TemplateAlias");
				string displayMode = overflowSection.AttributeValue("DisplayMode");
				if (displayMode == "Large") displayMode = "Lg";
				if (displayMode == "Medium") displayMode = "Md";
				if (displayMode == "Small") displayMode = "Sm";

				this.SectionTemplateAlias.Text = string.Format(" {0}/{1} ", templateAlias, displayMode);

				StringBuilder sb = new StringBuilder();
				sb.AppendLine("Template Alias: " + templateAlias);
				sb.AppendLine("Display Mode: " + overflowSection.AttributeValue("DisplayMode"));
				this.SectionTemplateAlias.ToolTip = sb.ToString();
			}
			else
			{
				this.SectionTemplateAlias.Text = string.Empty;
			}
		}

		private bool _showTemplateAlias = false;
		public bool ShowTemplateAlias
		{
			get { return _showTemplateAlias; }
			set
			{
				_showTemplateAlias = value;
				if (_showTemplateAlias)
				{
					SectionBorder.BorderThickness = new Thickness(1, 1, 1, 1);
					SectionTemplateAlias.Visibility = System.Windows.Visibility.Visible;
				}
				else
				{
					SectionBorder.BorderThickness = new Thickness(0);
					SectionTemplateAlias.Visibility = System.Windows.Visibility.Collapsed;
				}
			}
		}



	}
}
